<?php
include 'include/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN"
"http://www.w3.org/tr/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/MAIN.dwt.php" codeOutsideHTMLIsLocked="false" -->
  <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>JoshHughes.com NFL Football Pool</title>
    <!-- InstanceEndEditable -->
	<link rel="stylesheet" href="css/football.css" type="text/css">
    <script src="scripts/prototype.js" type="text/javascript"></script>
	<script src="scripts/scriptaculous.js" type="text/javascript"></script>
	<script type="text/javascript">
	// Dynamic Iframe loader
	function loadIframe(theFrame, theURL) {
		document.getElementById(theFrame).src=theURL;
	}
	
	// resizes Iframe according to content
	function resizeMe(obj){ 
	docHeight = mainContent.document.body.scrollHeight
	 obj.style.height = docHeight + 'px'
	 } 
	</script>
    <!-- InstanceBeginEditable name="head" -->
    <script type="text/javascript">
		<!--
		// set your interval in milliseconds
                
		// this reloads the iframe, and triggers the next reload interval
		function doreload()
		{
			var reloadInterval = 50000;     //50 seconds
			var iframe = document.getElementById('scoresframe');
			if (!iframe) return false;
			iframe.src = iframe.src;
			setTimeout("doreload()", reloadInterval);
		}
		-->
	</script>
    <!-- InstanceEndEditable -->
  </head>
<body>
<div id="pagewidth" >
	<div id="header" >
	
		<?PHP include_once("layout/header.html"); ?>
		
	</div>
			<div id="wrapper" class="clearfix" > 
			<div id="maincol" >

			<!-- InstanceBeginEditable name="Contents" -->					
						<h2>Game Day Scores</h2>
						<?php
                        dbConnect();                                 
						//check to see if a Weeknum value was passed, if not, set WeekNum to CurrWeek.
						if (($Weeknum == NULL) || ($Weeknum == ""))
						{
							$Weeknum = getWeek();
						}
												
						//check to make sure $Weeknum > 1 AND $Weeknum < 21
						$Weeknum = checkWeekBounds($Weeknum);
						if (gameInProgress($Weeknum))
						{
							?>
							<script type="text/javascript">setTimeout('doreload()',30000);</script>
							<?
						}
						else
						{
							$NumMins = 10;
							$TimeOutSecs = $NumMins * 60000;
							
						}
						?>
						<br/>
						<form action="<? echo $PHP_SELF; ?>" method="POST" name="WeekForm">
							<table bgcolor="#FFFFFF" callpadding="0" cellspacing="0" width="575">
								<tr>
									<td width="325" align="center">&nbsp;</td>
									<td width="250" align="right" valign="top">
									<a href="<? echo $PHP_SELF; ?>?Weeknum=<? echo $Weeknum-1; ?>" class="permLink">Prev</a> | <a href="<? echo $PHP_SELF; ?>?Weeknum=<? echo $Weeknum+1; ?>" class="permLink">Next</a> &nbsp; or &nbsp; 
										<B>Go to:</B><?	WeekDropDown($Weeknum)	?>
									</td>
								</tr>
							</table>
						</form>
					<div class="redbg" style="width: 575px; padding: 2px;">
						<table width="100%" cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td align="left"><span class="whitelink">View Game Scores</span></td>
								<td align="right"><img src="images/showhide.gif" title="Show/Hide Scores" alt="Show/Hide Scores" border="0"  onclick="new Effect.toggle('scoresframe', 'blind');" /></td>
							</tr>
						</table><iframe id="scoresframe" name="scoresframe" src="../rss/week<?= $Weeknum; ?>.xml" height="350" width="100%" frameborder="0" scrolling="no" ></iframe>
					</div>
			<!-- InstanceEndEditable -->
			
			</div>
			<div id="leftcol" >
			
				<?PHP include_once("layout/left_column.php"); ?>
		
			</div>
			
		</div>
		
		<div id="footer" >
		
			<?PHP include_once("layout/footer.html"); ?>
			
		</div>
</div>
</body>
<!-- InstanceEnd --></html>
